<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <!-- basic styles -->
        <link href="../../assets/js/plugin/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link type="text/css" rel="stylesheet" href="../../assets/js/plugin/jquery-ui/css/jquery-ui.css" />
        <!--<link href="../../assets/js/plugin/datepicker/css/jquery-datepicker.css" rel="stylesheet" media="screen" />-->
        <!--<link href="../../assets/js/plugin/check/check.css" rel="stylesheet" media="screen" />-->
        <link rel="stylesheet" href="../../assets/css/ace.min.css" />
        <link rel="stylesheet" type="text/css" media="all" href="../../assets/js/date-time/daterangepicker-bs3.css"/>
        <style>
            .controls span.help-inline {
                font-size: 12px;
                color: #999
            }
            .modal-body{max-height: 200px;}
            .form-horizontal .row-fluid .left{
                float: left;
                width: 50%;
                margin: 0px;
                padding: 0px;
            }
            .header{padding-left:20px; margin-top: 20px;}
            .row-fluid{border-bottom: 1px solid #d5e3ef;margin-bottom: 10px}
        </style>

    </head>

    <body>
        <div class="main-container">
            <h4 style="" class='header smaller lighter blue'>用户组归属策略</h4>
            <form class="form-horizontal">
                <div class="row-fluid">
                    <div class="left">
                        <div class="control-group">
                            <label class="control-label" for="policy_desc">策略名称:</label>
                            <div class="controls">
                                <input class="policy_desc" name="policy_desc" type="text" id="policy_desc" placeholder="" required>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="UserGroupNo">用户组号:</label>
                            <div class="controls">
                                <input class="UserGroupNo" name="UserGroupNo" type="text" id="UserGroupNo" placeholder="" required>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="utype1">帐号用户：</label>
                            <div class="controls">
                                <textarea id="utype1" style="height:100px;" readonly></textarea>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="utype3">根据DPI监控链路来设置组：</label>
                            <div class="controls">
                                <textarea id="utype3" style="height:100px;" readonly></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="left">
                        <div class="control-group">
                            <label class="control-label" for="UserGroupName">用户组名:</label>
                            <div class="controls">
                                <input class="UserGroupName" name="UserGroupName" type="text" id="UserGroupName" placeholder="" required>
                            </div>
                        </div>
                    </div>
                    <div class="left">
                        <div class="control-group">
                            <label class="control-label" for="Action">操作:</label>
                            <div class="controls">
                                <select id="Action" disabled>
                                    <option value="1">增加用户</option>
                                    <option value="2">删除用户</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="left">
                        <div class="control-group">
                            <label class="control-label" for="utype2">IP地址段用户：</label>
                            <div class="controls">
                                <textarea id="utype2" style="height:100px;" readonly></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="left">
                        <div class="control-group">
                            <label class="control-label" for="utype4">根 据 用 户 上 线 时 所 在BRAS IP地址(NAS_IP_Address)来设置组：</label>
                            <div class="controls">
                                <textarea id="utype4" style="height:100px;" readonly></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <!--Web类别-->
                <div class=" row-fluid">
                    <div class="control-group" style=" margin-left: -200px;">
                        <div class="controls">
                            <a href="javascript:void(0)" class="btn btn-danger" onclick="previous1()">&nbsp;返&nbsp;回&nbsp;</a>
                        </div>
                    </div>
                </div>
            </form>
        </div>

        <script src="../../assets/js/jquery.js"></script>
        <script src="../../assets/js/plugin/bootstrap/js/bootstrap.min.js"></script>
        <script type='text/javascript' src="../../assets/js/plugin/jquery-ui/jquery-ui.js"></script>
        <!--<script src="../../assets/js/plugin/datepicker/js/jquery-datepicker.js"></script>-->
        <script src="../../assets/js/date-time/moment.js"></script>
        <script src="../../assets/js/date-time/daterangepicker.js"></script>
        <script src="../../assets/js/plugin/menu/menu.js"></script>
        <script src="../../assets/js/jquery.validate.js"></script>
        <script src="../../assets/js/jquery.validate-util.js"></script>
        <!--<script src="../../assets/js/logic/overlayer.js"></script>-->
        <script src="../../assets/js/Base64.js"></script>
        <script type="text/javascript">
            
            //获取url参数
            function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                var r = window.location.search.substr(1).match(reg);
                if (r != null)
                    return unescape(r[2]);
                return null;
            }

            var base64 = new Base64();
            var type=getQueryString("type");
            var id = getQueryString("id");
            var DepotID = getQueryString("DepotID");
            var DepotName = getQueryString("DepotName");
            DepotName = base64.decode(DepotName);

            function showData(resp) {
                        var messageType = resp.MessageType;
                        var messageNo = resp.MessageNo;
                        var instanceName = resp.Instance;
                        var comment = resp.Comment;
                        PolicyObj = resp.Content;
                        var us = PolicyObj.Users.User;
                        
                        $(".policy_desc").val(comment);

                        $("#UserGroupName").val(PolicyObj.UserGroupName);
                        $("#UserGroupNo").val(PolicyObj.UserGroupNo);
                        $("#Action").val(PolicyObj.Action);

                        if(!us.length){
                            switch(us.UserType){
                                case '1':
                                    $("#utype1").val($("#utype1").val()+us.UserName+"\n");
                                    break
                                case '2':
                                    $("#utype2").val($("#utype2").val()+us.UserName+"\n");
                                    break
                                case '3':
                                    $("#utype3").val($("#utype3").val()+us.UserName+"\n");
                                    break
                                case '4':
                                    $("#utype4").val($("#utype4").val()+us.UserName+"\n");
                                    break
                            }
                            return 
                        };
                        try{
                            for (var i = us.length - 1; i >= 0; i--) {
                                switch(us[i].UserType){
                                    case '1':
                                        $("#utype1").val($("#utype1").val()+us[i].UserName+"\n");
                                        break
                                    case '2':
                                        $("#utype2").val($("#utype2").val()+us[i].UserName+"\n");
                                        break
                                    case '3':
                                        $("#utype3").val($("#utype3").val()+us[i].UserName+"\n");
                                        break
                                    case '4':
                                        $("#utype4").val($("#utype4").val()+us[i].UserName+"\n");
                                        break
                                }
                            };
                        }catch(e){}
            }


            //返回上一级
            function previous1() {
                window.location = "../policyList.html?type=" + type + "&id=" + DepotID + "&name=" + base64.encode(DepotName) + "";
            }


            $(function(){
                $.ajax({
                    method:"POST",
                    async: false,
                    url: "../../action/policy/get.do",
                    dataType: "json",
                    data: {type: type, messageNo: id, instance: DepotName},
                    success: showData
                });
            })
        </script>
    </body>
</html>
